#!/usr/bin/python

import glob

PRE = """
<PROGRAM> @ PROGRAM id <COMMAND> ENDPROGRAM id
<COMMAND> @ <CONTROLE_INTRINSC> <COMMAND> | %
<CONTROLE_INTRINSC> @ <IF> | <DO> | <FUNC_INTR> | <READ> | <WRITE>
<IF> @ IF ( id ) <COMMAND> ENDIF
<FUNC_INTRINS> @ SQRT ( token_LitInteger ) | POW ( token_LitInteger, token_LitInteger) | MOD (  token_LitInteger, token_LitInteger)
<DO> @  DO id ( token_LitInteger) , ( token_LitInteger) , ( token_LitInteger ) <COMMAND> ENDDO
<WRITE> @ WRITE ( tokenAst , tokenAst ) <SAIDA_WRITE>
<SAIDA_WRITE> @ id | token_LitString
<READ> @ READ ( tokenAst , tokenAst ) id
"""
POS = """
P -> p i C e i
C -> C_ C | %
C_ -> I D F R W
I -> 'if' ( i ) C 'e_if'
F -> 'sqr' ( 5 ) | 'pow' ( 5 , 5 ) | 'mod' ( 5 , 5 )
D -> d i ( 5) , ( 5 ) , ( 5 ) , C , 'e_do'
W -> w ( * , * ) i
S -> i | ""
R -> r ( * , * ) i
"""

T = dict()
def preparaMapa():
    for k, v in zip( PRE.split(), POS.split() ):
        T[k]
    T = dict.fromkeys(PRE.split(), POS.split())

if __name__ == "__main__":
    filenames = glob.glob("*.rec.4f")
    preparaMapa()
    print T
    for k in sorted(T.keys()):
        print T[k]
